Subscriptions
Subscribing to activities and events ensures you have up to date information without having to consume the additional network and cpu resources which would be required if you continuously polled for the data. To receive notifications you indicate the actives you wish to receive updates for as well as provide an endpoint which Net2Phone Canada can POST data to. NOTE: All POST messages will contain JSON data.
Create A Subscription
Before you can receive subscriptions from Integrate you must first set up and endpoint on your application server which will receive the subscribed to data. When the objects you are interested in are created or updated your subscribed endpoint will be notified. The important thing to ensure is that your provided endpoint is able to receive POST requests and provide a successful response (200, 204 response). NOTE: The JSON message will be provided in a POST request to your subscribed endpoint. If you would like to renew an existing subscription simply issue your subscribe request again.
Method: | POST |
API Documentation: | Subscriptions |
URL: | https://integrate.versature.com/api/subscriptions/ |
Request: |
|
Response: |
|
Subscription Initialization
Subscriptions are set up asynchronously and can take a few seconds to initialize after a successful creation. You will receive two messages at your endpoint (subscribed url) as we initialize your subscription.
{'msg': 'Preparing subscription for: calls', 'state': 'preparing'}
{'msg': 'You have been subscribed to your requested subscriptions.', 'state': 'ready'}
Request Parameters
Your subscription request will contain the following parameters.
Field | Description |
---|---|
post_uri | The endpoint which is notified when an event occurs. |
expires_in | The number of seconds until the subscription expires. The maximum value is 604800 |
calls | A boolean value which will be set to True if you wish to subscribe to Call events. |
cdrs | A boolean value which will be set to True if you wish to subscribe to Call Detail Records (CDRs). |
user | The users for which you would like to receive notifications for. This property can be repeated so that you can subscribe to multiple users. |
Success Response
If your subscription request is successful your response will contain the following data
Field | Description |
---|---|
id | The unique id of this subscription. |
expires | When thie subscription expires. This Date/Time is UTC and is in ISO-8601 format. |
post_uri | The endpoint which is notified when an event occurs. |
type | The type of events which notifications will be sent for. |
Renew A Subscription
If you would like to renew an existing subscription simply resend the request you used to create the subscription before your subscription expires. The expires_in field will set a new expiry date in the future and your subscription (with the same ID) will remain active.
Get Subscription Details
The ID that is acquired when first creating a subscription can be used to get the details about an existing subscription. You can confirm when the subscription will expire as well as the events which are subscribed to.
Method: | GET |
API Documentation: | Subscriptions |
URL: | https://integrate.versature.com/api/subscriptions/{subscriptions_id}/ |
Request: |
|
Response: |
|
Subscription Messages
Requests will delivered to your subscribed endpoint for each event you are interested in. These JSON messages will contain information about new or updated objects.
Remove Subscription
Delete a subscription with the provided ID. Subscriptions will terminate on their own on their expiry date/time but they can be removed prior to this date/time through a delete request.
Method: | DELETE |
API Documentation: | Delete Subscription |
URL: | https://integrate.versature.com/api/subscriptions/{subscriptions_id}/ |
Request: |
|
Response: |
|